using System;
using System.Workflow.ComponentModel.Compiler;

namespace OWA.Activities
{
	class AbstractPackageActivityValidator
        : ActivityValidator
	{
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
        {
            ValidationErrorCollection errors = base.Validate(manager, obj);
            AbstractPackageActivity activity = obj as AbstractPackageActivity;
            if (activity != null && activity.Parent != null)
            {
                if (activity.Package == null && 
                    activity.IsBindingSet(AbstractPackageActivity.PackageProperty) == false)
                {
                    errors.Add(new ValidationError("The Package property is required to be specified for the activity to function normally.", 1));
                }
            }
            return errors;
        }
	}
}
